---
title: Image Generation
description: Use image generation like OpenAI DALL-E Stable Diffusion to
  generate images from text.
sidebar:
  order: 41
hero:
  image:
    alt: A small, square minimalist illustration shows a geometric computer
      interface using colorful flat shapes. A paintbrush and an image icon are
      arranged in a simple design, with symbolic elements alluding to
      technology, large language model providers, and cloud connectivity. The
      image is abstract, highly stylized, and uses only five solid colors
      without any text, people, shadow, or background, highlighting a clean,
      modern, corporate aesthetic.
    file: ./image-generation.png

---

GenAIScript support LLM providers with [OpenAI-compatible image generation APIs](https://platform.openai.com/docs/guides/images).

## Supported providers

You will need to configure a LLM provider that support image generation.

- [OpenAI](/genaiscript/configuration/openai)
- [Azure OpenAI](/genaiscript/configuration/azure-openai)
- [Azure AI Foundry](/genaiscript/configuration/azure-ai-foundry)

## Generate an image

The top-level script (main) cannot be configured to generate an image at the moment; it has be done a function call to `generateImage`.

`generateImage` takes a prompt and returns an image URL and a revised prompt (optional).

```js "generateImage" wrap
const { image, revisedPrompt } = await generateImage(
    `a cute cat. only one. photographic, high details. 4k resolution.`
)
```

The `image` object is an image file that can be passed around for further processing.

```js
env.output.image(image.filename)
```